﻿using Microsoft.AspNetCore.Mvc;
using MyTodoApi.Context;
using MyTodoApi.Services;
using Shared.ToDo.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyTodoApi.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class MemoController : Controller
    {
        private readonly IMemoService memoService;

        public MemoController(IMemoService memoService)
        {
            this.memoService = memoService;
        }

        [HttpGet]
        public async Task<ApiResponse> GetByIdAsync(int id) => await memoService.GetById(id);

        [HttpGet]
        public async Task<ApiResponse> GetAllAsync() => await memoService.GetAsync();

        [HttpPost]
        public async Task<ApiResponse> AddAsync([FromBody] MemoDto memo) => await memoService.AddAsync(memo);

        [HttpPost]
        public async Task<ApiResponse> UpdateAsync([FromBody] MemoDto memo) => await memoService.UpdateAsync(memo);

        [HttpDelete]
        public async Task<ApiResponse> DeleteAsync(int id) => await memoService.Delete(id);

    }
}
